package com.netmera.mobile;

import v2.simpleUi.M_Button;
import v2.simpleUi.M_Caption;
import v2.simpleUi.M_Container;
import v2.simpleUi.M_EmailInput;
import v2.simpleUi.M_InfoText;
import android.app.Activity;
import android.content.Context;
import android.widget.Button;

public class M_UserContentInfoView extends M_Container {

	public M_UserContentInfoView(final Activity activity,
			final NetmeraContent userContent) throws NetmeraException {

		String nickname = userContent.getString("nickname");

		add(new M_Caption("User Details"));
		add(new M_InfoText("Nickname", nickname));
		try {
			String about = userContent.getString("about");
			if (about != null && !about.equals("")) {
				add(new M_InfoText("About " + nickname + ":"));
				add(new M_InfoText(about));
			}
		} catch (NetmeraException e1) {
			e1.printStackTrace();
		}
		add(new M_InfoText("Last checkin", ""
				+ userContent.getUpdateDate().toLocaleString()));
		add(new M_Button("Send message to " + nickname) {

			@Override
			public void onClick(Context context, Button clickedButton) {
				try {
					M_EmailInput.sendMail(activity,
							userContent.getString("email"), "", "");
				} catch (NetmeraException e) {
					e.printStackTrace();
				}
			}
		});
		add(new M_InfoText("First checkin", ""
				+ userContent.getCreateDate().toLocaleString()));
	}

}
